//
//  YXIntroduceViewController.m
//  跑跑快销
//
//  Created by 杨潇 on 14-5-4.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "YXIntroduceViewController.h"

@interface YXIntroduceViewController ()

@end

@implementation YXIntroduceViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _introduceVi = [[YXIntroduceView alloc] init];
    self.view = _introduceVi;
    
    _introduceVi.scrollVi.delegate = self;
    [_introduceVi.pageControl addTarget:self action:@selector(pageControlChange:) forControlEvents:UIControlEventValueChanged];
}

- (void)pageControlChange:(UIPageControl *)pageCon
{
    int offsetX = pageCon.currentPage * 320;
    _introduceVi.scrollVi.contentOffset = CGPointMake(offsetX, 0);
}

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    int page = scrollView.contentOffset.x/320;
    _introduceVi.pageControl.currentPage = page;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
